package com.nbcio.pm.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.nbcio.common.tenant.core.TenantEntity;
import com.nbcio.pm.domain.vo.PmProjectVo;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 项目对象 pm_project
 *
 * @author nbacheng
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pm_project")
@AutoMapper(target = PmProjectVo.class, reverseConvertGenerate = false)
public class PmProject extends TenantEntity {

    /**
     * 项目ID
     */
    @TableId(value = "project_id", type = IdType.AUTO)
    private Long projectId;

    /**
     * 项目名称
     */
    @TableField("project_name")
    private String projectName;

    /**
     * 项目编码
     */
    @TableField("project_code")
    private String projectCode;

    /**
     * 项目描述
     */
    @TableField("description")
    private String description;

    /**
     * 项目类型：normal-普通项目，template-模板项目
     */
    @TableField("project_type")
    private String projectType;

    /**
     * 项目状态：planning-规划中，active-进行中，completed-已完成，paused-已暂停，cancelled-已取消
     */
    @TableField("status")
    private String status;

    /**
     * 优先级：low-低，medium-中，high-高，urgent-紧急
     */
    @TableField("priority")
    private String priority;

    /**
     * 开始日期
     */
    @TableField("start_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDate;

    /**
     * 结束日期
     */
    @TableField("end_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDate;

    /**
     * 实际开始日期
     */
    @TableField("actual_start_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate actualStartDate;

    /**
     * 实际结束日期
     */
    @TableField("actual_end_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate actualEndDate;

    /**
     * 进度百分比
     */
    @TableField("progress")
    private BigDecimal progress;

    /**
     * 预算
     */
    @TableField("budget")
    private BigDecimal budget;

    /**
     * 实际成本
     */
    @TableField("actual_cost")
    private BigDecimal actualCost;

    /**
     * 项目经理ID
     */
    @TableField("manager_id")
    private Long managerId;

    /**
     * 客户ID
     */
    @TableField("client_id")
    private Long clientId;

    /**
     * 模板ID
     */
    @TableField("template_id")
    private Long templateId;

    /**
     * 是否为模板
     */
    @TableField("is_template")
    private Boolean isTemplate;

    /**
     * 是否公开
     */
    @TableField("is_public")
    private Boolean isPublic;

    // 关联字段（非数据库字段）
    @TableField(exist = false)
    private String managerName;

    @TableField(exist = false)
    private String clientName;

    @TableField(exist = false)
    private List<PmTask> tasks;

    @TableField(exist = false)
    private List<PmProjectMember> members;
}
